import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
@WebServlet("/demo2")
public class ServletDemo2 extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //1. 准备数据
        List<User> users = new ArrayList<User>();
        users.add(new User(1,"加维","男",20,"斗牛士军团",1));
        users.add(new User(2,"克洛泽","男",37,"德意志战车",0));
        users.add(new User(3,"哈里凯恩","男",33,"三狮军团",1));


        //2. 存储到request域中
        request.setAttribute("users",users);
        request.setAttribute("status",1);

        //3. 转发到 jstl.jsp
        request.getRequestDispatcher("/jstl.jsp").forward(request,response);
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doGet(request, response);
    }
}